package com.frxuexi.base.net

import android.content.Context
import androidx.room.Room
import com.frxuexi.base.db.ParkDataBase
import com.frxuexi.base.db.VideoDao
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object ProviderFactory {

    @Singleton
    @Provides
    fun apiServiceToken(): ApiService = getServiceToken()

    @Singleton
    @Provides
    fun database(@ApplicationContext context: Context): ParkDataBase =
        Room.databaseBuilder(context, ParkDataBase::class.java,"video2209.db")
            .allowMainThreadQueries()
            .build()

    @Singleton
    @Provides
    fun videoDao(dataBase: ParkDataBase):VideoDao=dataBase.getVideoDao()
}